package com.example.demo.common.com.example.demo;

import org.apache.commons.lang.StringUtils;

import java.util.Objects;

public class Demo04 {

    public static void main(String[] args) {

        // 获取表的别名
        String tableAlias = "b";
        if (StringUtils.isNotBlank(tableAlias)) {
            tableAlias += ".";
        }
        StringBuilder sqlFilter = new StringBuilder();

        String[] userIds = "KfID,customer_service_id".split(",");
        sqlFilter.append("( ");
        for (int i = 0; i < userIds.length; i++) {
            String selectUserId = userIds[i];
            if (i == userIds.length - 1) {
                sqlFilter.append(tableAlias).append(selectUserId).append(" in (").append("select ID from dbo.TTAdmin where deleted=0 and dept_path = '").append("6666").append("'").append(")");
            } else {
                sqlFilter.append(tableAlias).append(selectUserId).append(" in (").append("select ID from dbo.TTAdmin where deleted=0 and dept_path = '").append("6666").append("'").append(")").append(" or ");
            }
        }
        sqlFilter.append(" )");

        System.out.println(sqlFilter.toString());
    }
}
